﻿using System;
using System.Collections.Generic;
using System.Linq;
using Zeus.Thunder.Core;

namespace SharpTrainer.Linq
{
    class EnumerableLinqTest : ITestCase
    {
        public void Run()
        {
            string[] names = { "Tom", "Dick", "Harry", "Mary", "Jay" };

            IEnumerable<string> query = names
                .Where(n => n.Contains("a"))
                .OrderBy(n => n.Length)
                .Select(n => n.ToUpper());

            foreach (string name in query) 
                Console.WriteLine(name);

            Console.WriteLine("Another way to filter the list:");

            query = from n in names
                    where n.Contains("a") // Filter elements
                    orderby n.Length // Sort elements
                    select n.ToUpper(); // Translate each element (project)

            foreach (string name in query)
                Console.WriteLine(name);
        }
    }
}

